var info = JSON.parse(localStorage.getItem("userInfo"));
var token
if (info) {
	token = info.token
} else {
	token = ''
}
var commonHeader = { // 公共header
	"Content-Type": "application/json",
	
}
//封装出去一个公共路径
function baseUrl() {
	 return "https://rht.jfzh.com.cn/"
	// return 'https://rht-test.jfzh.com.cn/'
}

function baseUrl1() {
	return 'https://rhtm.jfzh.com.cn/'
	// return 'https://rht-admin-test.jfzh.com.cn/'
}

//公共ajax封装
function wxAjax(url, type, params, successfn, errorfn) {
	if (type == 'get' || type == 'GET') {
		if (params) {
			let str = ''
			for (var i in params) {
				str += i + '=' + params[i] + '&';
			}
			params = str.substring(0, str.length - 1)
		}
	} else {
		params = JSON.stringify(params)
	}
	$.ajax({
		url: url,
		type: type,
		headers: commonHeader,
		data: params,
		success: function (res) {
			if (res.code != 200) {
				let sendMsg = ''
				if (res.msg) {
					sendMsg = res.msg
				} else {
					sendMsg = res.message
				}
				showMessage(sendMsg, 0);
			} else {
				successfn(res)
			}
		},
		error: function (res) {
			// errorfn(res);
			console.log(res)
		},
		complete: function () {
			// console.log('结束 看需要写不写');
		}
	});

}

//消息提示
function showMessage(message, type) {
	let messageJQ = $("<div class='showMessage'>" + message + "</div>");
	if (type == 0) {
		messageJQ.addClass("showMessageError");
	} else if (type == 1) {
		messageJQ.addClass("showMessageSuccess");
	}
	/**先将原始隐藏，然后添加到页面，最后以600秒的速度下拉显示出来*/
	messageJQ.hide().appendTo("body").slideDown(600);
	/**3秒之后自动删除生成的元素*/
	window.setTimeout(function () {
		messageJQ.remove();
	}, 2000);
}